package com.wmx.thread.atomic;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;

/**********************************
 * @author wmx
 * @date 2019/8/22 10:53
 * @description:
 * @version 1.0
 ************************************/
public class Test {
    public static void main(String[] args) {
       /* Person person = new Person(100,"张三");
        System.out.println(person.hashCode());
        person.setName("李四");
        System.out.println(person.hashCode());

        Person person1 = new Person(100,"张三");
        Person person2 = new Person(101,"李四");

        Map<Object,String> map = new HashMap<>();
        map.put(person,"0000");
        map.put(person1,"1111");
        map.put(person2,"2222");
        System.out.println(map.get(person));
        System.out.println(map.get(person1));
        System.out.println(map.get(person2));*/

        String s1 = new String("abc");
        String s2 = new String("abc");
        HashMap hm = new HashMap();
        hm.put(s1, 1);
        hm.put(s2, 2);
        System.out.println(hm.get(s1));
        System.out.println(hm.get(s2));
        System.out.println(hm.size());

        StringBuilder sb1 = new StringBuilder("abc");
        StringBuilder sb2 = new StringBuilder("abc");

        HashMap hm1 = new HashMap();
        hm1.put(sb1, 1);
        hm1.put(sb2, 2);
        System.out.println(hm1.size());




    }

}

@Getter
@Setter
@AllArgsConstructor
class Person{
    private int id ;
    private String name ;

  /*   @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + id;
        return result;
    }*/
}